<?php if (!defined("BASEPATH")) exit("No direct script access allowed"); ?>

<div id="DataEditContainer"></div>

<?
$is_editable = FALSE;
foreach($editable as $type_editable) {
	if($type_editable) $is_editable = TRUE;
}
//Common::pr($editable); exit;
?>

<script type="text/javascript">

	Ext.onReady(function() {

		Ext.ns('Extamples');
		Extamples.CropWindowUi = Ext.extend(Ext.Window, {
		  title: '<?=$this->db->escape_str($this->lang->line("IMAGE_CROP"))?>',
		  width: 920,
		  height: 570,
		  modal: true,
		  initComponent: function() {
			this.fbar = {
			  xtype: 'toolbar',
			  items: [
				{
				  xtype: 'button',
				  text: '<?=$this->db->escape_str($this->lang->line("CANCEL"))?>',
				  ref: '../buttonCancel'
				},
				{
				  xtype: 'button',
				  text: '<?=$this->db->escape_str($this->lang->line("SAVE"))?>',
				  ref: '../buttonSave'
				}
			  ]
			};
			Extamples.CropWindowUi.superclass.initComponent.call(this);
		  }
		});

		Extamples.CropWindow = Ext.extend(Extamples.CropWindowUi, {
			cropData: null,
			imageUrl: '',
			e2iId: '',
			initComponent: function() {
			
			// I am using an image preloader here, for getting the initial height and width
			//
			Extamples.CropWindow.superclass.initComponent.call(this);
			var imgLoad = new Image();
			imgLoad.onload = (function(){
				this.setSize(imgLoad.width + 20, imgLoad.height + 70);
				var crop = new Ext.ux.ImageCrop({
					imageUrl: this.imageUrl,
					initialWidth: 660, //imgLoad.width,
					minWidth: 660,
					minHeight: 350,
					initialHeight: 350, //imgLoad.height,
					imgWidth: imgLoad.width,
					imgHeight: imgLoad.height,
					quadratic: false
				});
				this.cropData = crop.getCropData();
				crop.on('change', function(foo,x) {this.cropData = x;}, this);
				this.add(crop);
			}).createDelegate(this);
			imgLoad.src = this.imageUrl;
			
			// handler for the buttons
			this.buttonCancel.on('click', this.close, this);
			this.buttonSave.on('click', this.saveCrop, this);
		  },
		  saveCrop: function() {
			//Ext.get('output-2').update('X Offset: '+this.cropData.x+' Y Offset: '+this.cropData.y+' Width: '+this.cropData.width+' Height: '+this.cropData.height);

			Ext.Ajax.request({
				url: '<?=site_url()?>admin/image_crop/' + this.e2iId, //this.imageUrl,
				method: 'post',
				params: this.cropData,
				success: function(){
					if(this.fireEvent('save', this) === false){
						return this;
					}
					this.close();
				},
				scope: this
			});

		  }
		});


		new Ext.Panel({
			layout: '',
			border: false,
			id: 'helpPanel',
			frame: true,
			collapsible:  false,
			renderTo: 'DataEditContainer',
			html: '<?=$this->db->escape_str($this->lang->line(($is_editable)?("ROWS_WITH_DIFFERENT_COLORS_EXISTS_UNPUBLISHED_DETAILS"):("YOU_DO_NOT_HAVE_PERMISSION_TO_EDIT_THE_DATA")))?>',
			padding: 5,
			style: {margin: '3px'}
		});

		<? if($is_editable) { ?>
		Ext.namespace('DataEdit');
		
		DataEdit.deferedLoad = function(insId) {
			Ext.getCmp('majGrid').getStore().load({params: {fields:'["insId"]', query: insId}});
		}

		DataEdit.delete = function(entity, id, name) {
			Ext.MessageBox.confirm('<?=$this->db->escape_str($this->lang->line("CONFIRMATION"))?>', '<?=$this->db->escape_str($this->lang->line("ARE_YOU_SURE_YOU_WOULD_LIKE_TO_DELETE_THE_ITEM"))?> (' + name + ')?' , function(btn) {
				if(btn == 'yes') {
					Ext.Ajax.request({url: '<?=site_url()?>admin/data_edit_insert_update', params: 'del=1&ENTITY=' + entity + '&ID=' + id, success: function() {
						Ext.getCmp(entity.toLowerCase() + 'Grid').getStore().reload(Ext.getCmp(entity.toLowerCase() + 'Grid').lastOptions);
						}
					});
				}
			});
		}

		DataEdit.publish = function(entity, id, name, publish) {
			Ext.MessageBox.confirm('<?=$this->db->escape_str($this->lang->line("CONFIRMATION"))?>', ((publish == 1)?('<?=$this->db->escape_str($this->lang->line("ARE_YOU_SURE_YOU_WOULD_LIKE_TO_PUBLISH_THE_ITEMS"))?>'):('<?=$this->db->escape_str($this->lang->line("ARE_YOU_SURE_YOU_WOULD_LIKE_TO_CANCEL_THE_UNPUBLISHED_DATA"))?>')) + ' (' + name + ')?' , function(btn) {
				if(btn == 'yes') {
					Ext.Ajax.request({url: '<?=site_url()?>admin/data_edit_insert_update', params: 'publish=' + publish + '&ENTITY=' + entity + '&ID=' + id, success: function() {
						Ext.getCmp(entity.toLowerCase() + 'Grid').getStore().reload(Ext.getCmp(entity.toLowerCase() + 'Grid').lastOptions);
						}
					});
				}
			});
		}

		DataEdit.unpublish = function(entity, id, name, publish) {
			Ext.MessageBox.confirm('<?=$this->db->escape_str($this->lang->line("CONFIRMATION"))?>', '<?=$this->db->escape_str($this->lang->line("ALL_UNPUBLISHED_DATA_WILL_BE_ERASED_ARE_YOU_SURE_TO_CONTINUE"))?>' , function(btn) {
				if(btn == 'yes') {
					Ext.Ajax.request({url: '<?=site_url()?>admin/data_edit_insert_update', params: 'publish=' + publish + '&ENTITY=' + entity + '&ID=' + id, success: function() {
						Ext.getCmp(entity.toLowerCase() + 'Grid').getStore().reload(Ext.getCmp(entity.toLowerCase() + 'Grid').lastOptions);
						}
					});
				}
			});
		}
		
		// -id ha uj
		DataEdit.showWindow = function(entity, id) {
			Ext.Ajax.request({
				url: '<?=site_url()?>admin/getCategoryVal',
				params: { entity: entity, id: id},
				scripts: true
			});
		}

		DataEdit.image = function(entity, id) {

			var tpl = new Ext.XTemplate(
			'<tpl for=".">',
				'<div class="thumb-wrap" id="ID{e2iId}" style="border:1px solid #DDDDDD;">',
					'<div class="thumb"><img src="<?=MEDIA?>../uploads/{e2iImageNameThumb}" title="{e2iAlt}"></div>',
					'<div class="alt">{e2iResizedWidth} x {e2iResizedHeight}</div>',
					'<div class="alt" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">{e2iAlt}</div>',
					'<div class="alt"><?=$this->db->escape_str($this->lang->line("SLIDER"))?>: {e2iCroppedText}</div>',
				'</div>',
			'</tpl>',
			'<div class="x-clear"></div>'
			);

			var store = new Ext.data.JsonStore({
				url: '<?=site_url()?>admin/get_ent2image/' + entity + '/' + id,
				root: 'images',
				fields: [
					'e2iId',
					'e2iCouId',
					'e2iCityId',
					'e2iInsId',
					'e2iImageName',
					'e2iImageNameOriginal',
					'e2iImageNameThumb',
					'e2iImageNameResized',
					'e2iAlt',
					'e2iWidth',
					'e2iHeight',
					'e2iThumbWidth',
					'e2iThumbHeight',
					'e2iResizedWidth',
					'e2iResizedHeight',
					'e2iCropped',
					'e2iImageNameCropped',
					'e2iCroppedText'
				]
			});
			store.load();

			if(entity == 'MAJ' || entity == 'INS' || entity == 'FAC') {
				var insImageStore = new Ext.data.JsonStore({
					url: '<?=site_url()?>admin/get_ins_ent2image/' + entity + '/' + id,
					root: 'images',
					fields: [
						'e2iId',
						'e2iCouId',
						'e2iCityId',
						'e2iInsId',
						'e2iImageName',
						'e2iImageNameOriginal',
						'e2iImageNameThumb',
						'e2iImageNameResized',
						'e2iAlt',
						'e2iWidth',
						'e2iHeight',
						'e2iThumbWidth',
						'e2iThumbHeight',
						'e2iResizedWidth',
						'e2iResizedHeight',
						'e2iCropped',
						'e2iImageNameCropped',
						'e2iCroppedText'
					]
				});
				insImageStore.load();
			}
			
			winImage = new Ext.Window({
				title:'<?=$this->db->escape_str($this->lang->line("MANAGING_IMAGES"))?>',
				bodyStyle: 'background-color:white',
				autoScroll: true,
				maximized: false,
				modal: true,
				width:700,
				floating: true,
				minWidth: 700,
				height:500,
				minHeight: 500,
				closeAction:'close',
				maximizable: false,

				items:[{

							border: false,

							items: [

								new Ext.Panel({
									id:'images-view',
									border: true,
									anchor: '100%',
									style: {margin: '3px'},
									autoHeight:true,
									collapsible:true,
									layout:'fit',
									title:'<?=$this->db->escape_str($this->lang->line("UPLOADED_IMAGES"))?>',

									tbar: {
										items: [{
												icon: '<?=MEDIA?>icon/application_form_delete.png',
												text: '<?=$this->db->escape_str($this->lang->line("DELETE"))?>',
												ref: '../removeBtn',
												id: 'removeBtn',
												disabled: true,
												handler: function(){
													Ext.MessageBox.confirm('<?=$this->db->escape_str($this->lang->line("CONFIRMATION"))?>', '<?=$this->db->escape_str($this->lang->line("ARE_YOU_SURE_YOU_WOULD_LIKE_TO_DELETE_THE_IMAGE"))?>' , function(btn) {
														if(btn == 'yes') {
															var remove = '';
															for(var i = 0; i < Ext.getCmp('thumbDataView').getSelectedRecords().length; i++) {
																remove += ((remove != '')?('|'):('')) + Ext.getCmp('thumbDataView').getSelectedRecords()[i].data.e2iId;
															}
															Ext.Ajax.request({url: '<?=site_url()?>admin/ent2image_insert_update', params: 'del=1&e2iId=' + remove, success: function() {
																store.reload();
																}
															});
														}
													});
												}
											}, {
												icon: '<?=MEDIA?>icon/application_form_add.png',
												text: '<?=$this->db->escape_str($this->lang->line("ADD_EDIT_TEXT"))?>',
												ref: '../addBtn',
												id: 'addBtn',
												disabled: true,
												handler: function(){

													Ext.MessageBox.show({
														title: '<?=$this->db->escape_str($this->lang->line("ADD_EDIT_TEXT"))?>',
														msg: '<?=$this->db->escape_str($this->lang->line("TEXT"))?>:',
														width:300,
														buttons: Ext.MessageBox.OKCANCEL,
														multiline: true,
														value: Ext.getCmp('thumbDataView').getSelectedRecords()[0].data.e2iAlt,
														fn: function(btn, text) {
															if(btn == 'ok') {
																var add = '';
																for(var i = 0; i < Ext.getCmp('thumbDataView').getSelectedRecords().length; i++) {
																	add += ((add != '')?('|'):('')) + Ext.getCmp('thumbDataView').getSelectedRecords()[i].data.e2iId;
																}
																Ext.Ajax.request({url: '<?=site_url()?>admin/ent2image_insert_update', params: 'e2iId=' + add + '&e2i_alt=' + text, success: function() {
																	store.reload();
																	}
																});
															}
														}
												 });

												}
											}, new Ext.Button({
												icon: '<?=MEDIA?>icon/image_edit.png',
												ref: '../cropBtn',
												id: 'cropBtn',
												disabled: true,
												text: '<?=$this->db->escape_str($this->lang->line("IMAGE_CROP"))?>',
												handler: function() {
												//getting the image URL from whereever you want
												var cw = new Extamples.CropWindow({
													imageUrl: '<?=UPLOADS?>' + Ext.getCmp('thumbDataView').getSelectedRecords()[0].data.e2iImageNameResized,
													e2iId: Ext.getCmp('thumbDataView').getSelectedRecords()[0].data.e2iId,
													listeners:{
														save: function(){
														  // handler if a crop was successfull, and the window was closed
														  store.reload();
														},
														scope: this
													}
												});
												cw.show();
											  }
											}),  new Ext.Button({
												icon: '<?=MEDIA?>icon/application_form_delete.png',
												ref: '../removecropBtn',
												id: 'removecropBtn',
												disabled: true,
												text: '<?=$this->db->escape_str($this->lang->line("REMOVE_FROM_SLIDER"))?>',
												handler: function() {
													if(Ext.getCmp('thumbDataView').getSelectedRecords()[0].data.e2iCropped == "I") {
														Ext.Ajax.request({url: '<?=site_url()?>admin/image_crop/' + Ext.getCmp('thumbDataView').getSelectedRecords()[0].data.e2iId, params: 'remove=1', success: function() {
															store.reload();
															}
														});
													}
											  }
											}),
											
											((entity == 'MAJ' || entity == 'INS' || entity == 'FAC')?(new Ext.Button({
												icon: '<?=MEDIA?>icon/application_form_add.png',
												text: '<?=$this->db->escape_str($this->lang->line("PREVIOUSLY_UPLOADED_IMAGES"))?>',
												handler: function() {
													insImageWindow = new Ext.Window({
														id: 'insimages-view',
														iconCls: 'application_form_add',
														bodyStyle: 'background-color:white',
														autoScroll: true,
														maximized: false,
														modal: true,
														width:800,
														floating: true,
														minWidth: 800,
														height:500,
														minHeight: 500,
														closeAction:'close',
														maximizable: false,
														title: '<?=$this->db->escape_str($this->lang->line("ADD_NEW"))?>',

														listeners: {
															close: function() {
																//store.reload(store.lastOptions);
															}
														},

														items:[
															new Ext.DataView({
															store: insImageStore,
															autoHeight:true,
															tpl: new Ext.XTemplate(
																	'<tpl for=".">',
																		'<div class="thumb-wrap" id="ID{e2iId}" style="border:1px solid #DDDDDD;">',
																			'<div class="thumb"><img src="<?=MEDIA?>../uploads/{e2iImageNameThumb}" title="{e2iAlt}"></div>',
																		'</div>',
																	'</tpl>',
																	'<div class="x-clear"></div>'
																	),
															id: 'thumbInsDataView',
															multiSelect: true,
															overClass:'x-view-over',
															itemSelector:'div.thumb-wrap',

															listeners: {
																selectionchange: {
																	fn: function(dv,nodes){
																		//Ext.getCmp('addInsImageBtn').setDisabled(nodes.length != 1);
																	}
																}
															}

															})
														],
														
														bbar: {
															items: [{
																text: '<?=$this->db->escape_str($this->lang->line("SAVE"))?>',
																handler: function() {
																	var par = '';
																	for(var i = 0; i < Ext.getCmp('thumbInsDataView').getSelectedRecords().length; i++) {
																		par += ((par)?('&'):('')) + 'e2iId[]=' + Ext.getCmp('thumbInsDataView').getSelectedRecords()[i].data.e2iId;
																	}
																	if(par) {
																		Ext.Ajax.request({url: '<?=site_url()?>admin/ent2image_insert_update/', params: par + '&copy=1&ENTITY=' + entity + '&ID=' + id, success: function() {
																			insImageWindow.close();
																			store.reload();
																			}
																		});
																	}
																},
																icon: '<?=MEDIA?>icon/disk.png'
															}, {
																xtype: 'tbseparator'
															},{
																text: '<?=$this->db->escape_str($this->lang->line("CANCEL"))?>',
																handler: function() {
																	insImageWindow.close();
																},
																icon: '<?=MEDIA?>icon/cancel.png'
															}],
															buttonAlign : 'right'
														}

												});
												insImageWindow.show(this);
											  }
											})):({}))
										]
									},

									items: new Ext.DataView({
										store: store,
										autoHeight:true,
										tpl: tpl,
										id: 'thumbDataView',
										multiSelect: true,
										overClass:'x-view-over',
										itemSelector:'div.thumb-wrap',

										listeners: {
											selectionchange: {
												fn: function(dv,nodes){

													Ext.getCmp('removeBtn').setDisabled(nodes.length < 1);

													Ext.getCmp('addBtn').setDisabled(nodes.length != 1);
													if(Ext.getCmp('addBtn').disabled)
														Ext.getCmp('addBtn').hide();
													else
														Ext.getCmp('addBtn').show();

													Ext.getCmp('cropBtn').setDisabled(nodes.length != 1 || Ext.getCmp('thumbDataView').getSelectedRecords()[0].data.e2iResizedWidth < 660 || Ext.getCmp('thumbDataView').getSelectedRecords()[0].data.e2iResizedHeight < 350);
													if(Ext.getCmp('cropBtn').disabled)
														Ext.getCmp('cropBtn').hide();
													else
														Ext.getCmp('cropBtn').show();

													Ext.getCmp('removecropBtn').setDisabled(nodes.length != 1 || Ext.getCmp('thumbDataView').getSelectedRecords()[0].data.e2iCropped != "I");
													if(Ext.getCmp('removecropBtn').disabled)
														Ext.getCmp('removecropBtn').hide();
													else
														Ext.getCmp('removecropBtn').show();

												}
											}
										}

									})
								}),

								new Ext.FormPanel({
									padding: 3,
									labelAlign: 'right',
									labelWidth: 100,
									autoHeight: true,
									autoWidth: true,
									border: false,
									defaultType: 'textfield',
									waitMsgTarget: true,
									items: [{
										xtype:'fieldset',
										title: '<?=$this->db->escape_str($this->lang->line("UPLOADING_IMAGES"))?>',
										autoHeight:true,
										layout: {
											type: 'anchor'
										},
										items: [new AwesomeUploader({
											awesomeUploaderRoot: '<?=MEDIA?>awesomeuploader/',
											uploadUrl: '<?=site_url()?>admin/file_upload',
											flashUploadUrl: '<?=site_url()?>admin/file_upload',
											extraPostData: {ENTITY: entity, ID: id},
											frame: true,
											disableFlash: true,
											gridHeight: 130,
											anchor: '100%',
											height:200,
											listeners: {
												fileupload: function() {
													store.reload();
												}
											}
											})
										]
									}]
							})

					]

				}],

				bbar: {
					items: [{
						text: '<?=$this->db->escape_str($this->lang->line("CLOSE"))?>',
						handler: function() {
							winImage.close();
						}
					}],
					buttonAlign : 'right'
				}

			}).show();
		}

		
		var Panel = new Ext.Panel({
			renderTo: 'DataEditContainer',
			id: 'pagePanel',
			border: false,
			layout: 'fit',
			layoutConfig: {
				titleCollapse: true,
				animate: true,
				activeOnTop: true
			},			
			listeners: {
				afterrender: function() {
					Ext.getCmp('pagePanel').setHeight(Ext.getCmp('centerRegion').getHeight()-36-Ext.getCmp('helpPanel').getHeight());
					//majorStore.load({params:{start:0, limit:10}});
				}
			},
			items: [

			new Ext.Panel({
				title: '<?=$this->db->escape_str($this->lang->line("CONTINENT"))?> / <?=$this->db->escape_str($this->lang->line("COUNTRY"))?> / <?=$this->db->escape_str($this->lang->line("CITY"))?> / <?=$this->db->escape_str($this->lang->line("INSTITUTE"))?>',
				items: [
				new Ext.TabPanel({
					id: 'DataEditTabs',
					autoScroll: true,
					border: false,
					enableTabScroll: true,
				}),
				],
				border: false,
				layout: 'anchor',
				defaults:{
					autoScroll:true
				},
				autoScroll: true
			})]
		});

		<? if($editable["CON"]) { ?>
		Ext.getCmp('DataEditTabs').add({
			title: '<?=$this->db->escape_str($this->lang->line("CONTINENT"))?>',
			id: 'Tab_CON',
			autoLoad:{url: '<?=site_url()?>admin/data_edit/CON', scripts:true},
			listeners: {
				activate: function(panel) {
					Ext.getCmp('Tab_CON').setHeight('auto');
				},
				afterrender: function() {
					Ext.getCmp('Tab_CON').setHeight('auto');
				}
			}
		});
		<? } ?>

		<? if($editable["COU"]) { ?>
		Ext.getCmp('DataEditTabs').add({
			title: '<?=$this->db->escape_str($this->lang->line("COUNTRY"))?>',
			id: 'Tab_COU',
			listeners: {
				activate: function(panel) {
					Ext.getCmp('DataEditTabs').getActiveTab().getUpdater().refresh();
					Ext.getCmp('Tab_COU').setHeight('auto');
				},
				afterrender: function() {
					Ext.getCmp('Tab_COU').setHeight('auto');
				}
			},
			autoLoad:{url: '<?=site_url()?>admin/data_edit/COU', scripts:true}
		});
		<? } ?>

		<? if($editable["CITY"]) { ?>
		Ext.getCmp('DataEditTabs').add({
			title: '<?=$this->db->escape_str($this->lang->line("CITY"))?>',
			id: 'Tab_CITY',
			listeners: {
				activate: function(panel) {
					Ext.getCmp('DataEditTabs').getActiveTab().getUpdater().refresh();
					Ext.getCmp('Tab_CITY').setHeight('auto');
				},
				afterrender: function() {
					Ext.getCmp('Tab_CITY').setHeight('auto');
				}
			},
			autoLoad:{url: '<?=site_url()?>admin/data_edit/CITY', scripts:true}
		});
		<? } ?>

		<? if($editable["INS"]) { ?>
		Ext.getCmp('DataEditTabs').add({
			title: '<?=$this->db->escape_str($this->lang->line("INSTITUTE"))?>',
			id: 'Tab_INS',
			listeners: {
				activate: function(panel) {
					Ext.getCmp('DataEditTabs').getActiveTab().getUpdater().refresh();
					Ext.getCmp('Tab_INS').setHeight('auto');
				},
				afterrender: function() {
					Ext.getCmp('Tab_INS').setHeight('auto');
				}
			},
			autoLoad:{url: '<?=site_url()?>admin/data_edit/INS', scripts:true}
		});
		<? } ?>

		<? if($editable["FAC"]) { ?>
		Ext.getCmp('DataEditTabs').add({
			title: '<?=$this->db->escape_str($this->lang->line("FACULTY"))?>',
			id: 'Tab_FAC',
			listeners: {
				activate: function(panel) {
					Ext.getCmp('DataEditTabs').getActiveTab().getUpdater().refresh();
					Ext.getCmp('Tab_FAC').setHeight('auto');
				},
				afterrender: function() {
					Ext.getCmp('Tab_FAC').setHeight('auto');
				}
			},
			autoLoad:{url: '<?=site_url()?>admin/data_edit/FAC', scripts:true}
		});
		<? } ?>

		<? if($editable["ACC"]) { ?>
		Ext.getCmp('DataEditTabs').add({
			title: '<?=$this->db->escape_str($this->lang->line("ACCOMODATION"))?>',
			id: 'Tab_ACC',
			listeners: {
				activate: function(panel) {
					Ext.getCmp('DataEditTabs').getActiveTab().getUpdater().refresh();
					Ext.getCmp('Tab_ACC').setHeight('auto');
				},
				afterrender: function() {
					Ext.getCmp('Tab_ACC').setHeight('auto');
				}
			},
			autoLoad:{url: '<?=site_url()?>admin/data_edit/ACC', scripts:true}
		});
		<? } ?>
		
		<? if($editable["MAJ"]) { ?>
		Ext.getCmp('DataEditTabs').add({
			title: '<?=$this->db->escape_str($this->lang->line("COURSES"))?>',
			id: 'Tab_MAJ',
			listeners: {
				activate: function(panel) {
					Ext.getCmp('DataEditTabs').getActiveTab().getUpdater().refresh();
					Ext.getCmp('Tab_MAJ').setHeight('auto');
				},
				afterrender: function() {
					Ext.getCmp('Tab_MAJ').setHeight('auto');
				}
			},
			autoLoad:{url: '<?=site_url()?>admin/data_edit/MAJ', scripts:true}
		});
		<? } ?>

		<? if($editable["SCH"]) { ?>
		Ext.getCmp('DataEditTabs').add({
			title: '<?=$this->db->escape_str($this->lang->line("SCHOLARSHIPS"))?>',
			id: 'Tab_SCH',
			listeners: {
				activate: function(panel) {
					Ext.getCmp('DataEditTabs').getActiveTab().getUpdater().refresh();
					Ext.getCmp('Tab_SCH').setHeight('auto');
				},
				afterrender: function() {
					Ext.getCmp('Tab_SCH').setHeight('auto');
				}
			},
			autoLoad:{url: '<?=site_url()?>admin/data_edit/SCH', scripts:true}
		});
		<? } ?>

		Ext.getCmp('DataEditTabs').setActiveTab(<?=(($editable["CON"])?(1):(0))?>);

		
		<? } ?>

	})

</script>